package com.think.oauth.user.model;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import javax.annotation.sql.DataSourceDefinition;

import org.apache.commons.collections4.map.HashedMap;
import org.apache.ibatis.javassist.expr.NewArray;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.oauth2.provider.ClientDetails;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.think.common.utils.JSonUtil;

@TableName("oauth_client_details")
public class OauthClientDetails {
	@TableId
	private String clientId;
	private String resourceIds;
	private String clientSecret;
	private String scope;
	private String authorizedGrantTypes;
	private String webServerRedirectUri;
	private String authorities;
	private Integer accessTokenValidity;
	private Integer refreshTokenValidity;
	private String additionalInformation;
	private String autoapprove;
	public String getClientId() {
		return clientId;
	}
	public void setClientId(String clientId) {
		this.clientId = clientId;
	}

	public void setResourceIds(String resourceIds) {
		this.resourceIds = resourceIds;
	}
	public String getClientSecret() {
		return clientSecret;
	}
	
	public void setClientSecret(String clientSecret) {
		this.clientSecret = clientSecret;
	}
	
	public void setScope(String scope) {
		this.scope = scope;
	}
	
	public void setAuthorizedGrantTypes(String authorizedGrantTypes) {
		this.authorizedGrantTypes = authorizedGrantTypes;
	}
	public String getWebServerRedirectUri() {
		return webServerRedirectUri;
	}
	public void setWebServerRedirectUri(String webServerRedirectUri) {
		this.webServerRedirectUri = webServerRedirectUri;
	}

	public void setAuthorities(String authorities) {
		this.authorities = authorities;
	}
	public Integer getAccessTokenValidity() {
		return accessTokenValidity;
	}
	public void setAccessTokenValidity(Integer accessTokenValidity) {
		this.accessTokenValidity = accessTokenValidity;
	}
	public Integer getRefreshTokenValidity() {
		return refreshTokenValidity;
	}
	public void setRefreshTokenValidity(Integer refreshTokenValidity) {
		this.refreshTokenValidity = refreshTokenValidity;
	}
	public void setAdditionalInformation(String additionalInformation) {
		this.additionalInformation = additionalInformation;
	}
	public String getAutoapprove() {
		return autoapprove;
	}
	public void setAutoapprove(String autoapprove) {
		this.autoapprove = autoapprove;
	}
	public String getResourceIds() {
		return resourceIds;
	}
	public String getScope() {
		return scope;
	}
	public String getAuthorizedGrantTypes() {
		return authorizedGrantTypes;
	}
	public String getAuthorities() {
		return authorities;
	}
	public String getAdditionalInformation() {
		return additionalInformation;
	}

	
//	@Override
//	public boolean isSecretRequired() {
//		return this.clientSecret != null && this.clientSecret.length()>0 ;
//	}
//	@Override
//	public boolean isScoped() {
//		// TODO Auto-generated method stub
//		return true;
//	}
//	@Override
//	public Set<String> getScope() {
//		String[]  tempStrings =this.scope.split(",");
//		Set<String> set = new HashSet<String>();
//		for (int i = 0; i < tempStrings.length; i++) {
//			set.add(tempStrings[i]);
//		}
//		return set;
//	}
//	@Override
//	public Set<String> getAuthorizedGrantTypes() {
//		String[]  tempStrings =this.authorizedGrantTypes.split(",");
//		Set<String> set = new HashSet<String>();
//		for (int i = 0; i < tempStrings.length; i++) {
//			set.add(tempStrings[i]);
//		}
//		return set;
//	}
//	@Override
//	public Set<String> getRegisteredRedirectUri() {
//		String[]  tempStrings =this.webServerRedirectUri.split(",");
//		Set<String> set = new HashSet<String>();
//		for (int i = 0; i < tempStrings.length; i++) {
//			set.add(tempStrings[i]);
//		}
//		return set;
//	}
//	@Override
//	public Collection<GrantedAuthority> getAuthorities() {
//		Collection<GrantedAuthority> result = new ArrayList<GrantedAuthority>();
//		String[] tempStrings =this.authorities.split(",");
//		for (int i = 0; i < tempStrings.length; i++) {
//			result.add(new SimpleGrantedAuthority(tempStrings[i]));
//		}
//		return result;
//	}
//	@Override
//	public Integer getAccessTokenValiditySeconds() {
//		return accessTokenValidity;
//	}
//	@Override
//	public Integer getRefreshTokenValiditySeconds() {
//		return refreshTokenValidity;
//	}
//	@Override
//	public boolean isAutoApprove(String scope) {
//		return false;
//	}
//	@Override
//	public Map<String, Object> getAdditionalInformation() {
//		Map<String, Object> result = new HashedMap<String, Object>();
//		try {
//			result = JSonUtil.fromJson(additionalInformation, Map.class);
//		} catch (Exception e) {
//			// TODO: handle exception
//		}
//		return result;
//	}
//	@Override
//	public Set<String> getResourceIds() {
//		String[]  tempStrings =this.resourceIds.split(",");
//		Set<String> set = new HashSet<String>();
//		for (int i = 0; i < tempStrings.length; i++) {
//			set.add(tempStrings[i]);
//		}
//		return set;
//	}
	
	

}
